import {
    createRouter,
    createWebHistory
} from 'vue-router'
import MainView from '../views/MainView.vue'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/login',
            name: 'login',
            component: () => import("@/views/login/LoginView.vue")
        },
        {
            path: '/',
            name: 'main',
            component: MainView,
            //redirect: '/order'
            children: [
                {
                  path: '/',
                  name: 'order',
                  component: () => import('@/views/OrderView.vue')
                },
                {
                  path: '/member',
                  name: 'member',
                  component: () => import('@/views/MemberView.vue')
                },
            ]
        },
        {
            path : "/:xxx(.*)*",
            name : "ErrorPage",
            component: () => import('@/views/error.vue')
        }

    ]
})

//路由全局前置守卫
router.beforeEach((to, form, next) => {
    next();
})

export default router